package com.administrator.kotlindemo1.adapter

import android.content.Context
import com.administrator.kotlindemo1.R
import com.administrator.kotlindemo1.bean.Person
import com.hazz.kotlinmvp.view.recyclerview.MultipleType
import com.hazz.kotlinmvp.view.recyclerview.ViewHolder
import com.hazz.kotlinmvp.view.recyclerview.adapter.CommonAdapter

/**
 * Created by Administrator on 2018/1/15.
 */
class MultiplePersonAdapter(mContext: Context, data: ArrayList<Person>?) : CommonAdapter<Person>(mContext, data!!, object : MultipleType<Person> {
    override fun getLayoutId(item: Person, position: Int): Int {
        return when {
            data?.get(position).type == 0 ->
                R.layout.list_layout_1

            data?.get(position).type == 1 ->
                R.layout.list_layout_2

            data?.get(position).type == 2 ->
                R.layout.list_layout_3

            else -> R.layout.list_layout_1
        }
    }

}) {
    override fun bindData(holder: ViewHolder, data: Person, position: Int) {
        when {
            data?.type == 0 -> {
                holder.setText(R.id.text_1, "这是layout1")
            }
            data?.type == 1 -> {
                holder.setText(R.id.text_2, "这是layout2")
            }
            data?.type == 2 -> {
                holder.setText(R.id.text_3, "这是layout3")
            }
        }
    }
}